package com.tony.mulitithread.utils;

import java.time.LocalTime;

public class AsyncTask implements Runnable{
    //服务对象
    private Object object;
    //服务方法
    private String methodName;
    //方法参数
    private Object[] args;

    public AsyncTask(Object object, String methodName, Object[] args){
        this.object = object;
        this.methodName = methodName;
        this.args = args;

    }
    @Override
    public void run() {
        LocalTime currentTime = LocalTime.now();
        try {
            System.out.println("开始时间：" + currentTime);
            //这里就用到了反射来进行执行具体的方法
            ReflectionUtil.invokeMethod(object,methodName,args);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            System.out.println("结束时间：" + currentTime);
        }

    }
}
